package com.yugao.fintech.antelope.base.config.remote;

import com.yugao.fintech.antelope.base.model.enums.ConfigDefineEnum;
import com.yugao.fintech.antelope.base.model.module.config.ConfigInfo;
import com.yugao.fintech.antelope.system.SystemApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

@Component
@Primary
@ConditionalOnBean(SystemApi.class)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class ConfigManageApiLocalImpl implements ConfigManageApi {
    @Autowired
    private SystemApi systemApi;

    @Override
    @Async("myTaskScheduler")
    public Future<ConfigInfo> getUseConfig(ConfigDefineEnum configDefine) {
        return new AsyncResult<>(systemApi.getUseConfig(configDefine));
    }
}
